package vip.sweet.biz.modular.product.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import vip.sweet.biz.modular.product.params.BizProductsAddParams;
import vip.sweet.biz.modular.product.service.BizProductsService;
import vip.sweet.common.enums.ResponseEnum;
import vip.sweet.common.response.CommonResponse;

/**
 * @author ASUS
 * @Date 2025/10/5 11:40
 * @Descripition
 */
@Tag(name = "业务逻辑产品控制器")
@RequestMapping("/biz/products")
@RestController
public class BizProductsController {
    @Resource
    private BizProductsService bizProductsService;
    @PostMapping("/add")
    @Operation(summary = "添加产品接口")
    public CommonResponse add(@RequestBody @Validated BizProductsAddParams bizProductsAddParams){
         return bizProductsService.add(bizProductsAddParams) ? CommonResponse.success("添加成功") : CommonResponse.error(ResponseEnum.ERROR, "添加失败");
    }
    @GetMapping("/list")
    @Operation(summary = "获取产品列表接口")
    public CommonResponse list(){
        return CommonResponse.success(bizProductsService.list());
    }
}
